// import chineseToPinYin from '@/lib/pinyin'
// import {devServer} from '/vue.config.js'

// console.log(devServer)
const armOptions = [
    {label: '-', value: null},
    {label: '1臂', value: 1},
    {label: '2臂', value: 2},
    {label: '3臂', value: 3},
    {label: '4臂', value: 4},
    {label: '全臂', value: 0}
]
// const robotOptions = [
//     {label: '-', value: null},
//     {label: '5号机', value: 5},
//     {label: '6号机', value: 6},
//     {label: '7号机', value: 7},
//     {label: '8号机', value: 8},
//     {label: '9号机', value: 9},
//     {label: '10号机', value: 10},
//     {label: '11号机', value: 11},
//     {label: '12号机', value: 12},
//     {label: '13号机', value: 13},
//     {label: '14号机', value: 14},
//     {label: '15号机', value: 15},
//     {label: '16号机', value: 16},
//     {label: '17号机', value: 17},
//     {label: '18号机', value: 18},
//     {label: '19号机', value: 19},
//     {label: '20号机', value: 20}
// ]

const robotOptions = [{label: '-', value: null}, ...Array.from({ length: 30 }, (item, index) => ({
  label: `${index + 1}号机`,
  value: index + 1
}))];

const statusOptions = [
    {label: '进行中', value: 'IN_PROGRESS'},
    {label: '完成', value: 'COMPLETED'},
    {label: '失败', value: 'FAILED'}
];
const handOptions = [
    {label: '-', value: null},
    {label: '左主手', value: 5},
    {label: '右主手', value: 6},
    {label: '全臂', value: 0}
];

// const consoleOptions = [
//     {label: '-', value: null},
//     {label: '5号机', value: 5},
//     {label: '6号机', value: 6},
//     {label: '7号机', value: 7},
//     {label: '8号机', value: 8},
//     {label: '9号机', value: 9},
//     {label: '10号机', value: 10},
//     {label: '11号机', value: 11},
//     {label: '12号机', value: 12},
//     {label: '13号机', value: 13},
//     {label: '14号机', value: 14},
//     {label: '15号机', value: 15},
//     {label: '16号机', value: 16},
//     {label: '17号机', value: 17},
//     {label: '18号机', value: 18},
//     {label: '19号机', value: 19},
//     {label: '20号机', value: 20}
// ];

const consoleOptions = [{label: '-', value: null}, ...Array.from({ length: 30 }, (item, index) => ({
  label: `${index + 1}号机`,
  value: index + 1
}))];

const typeOptions = [
    {label: '臂系统', value: 'ROBOT'},
    {label: '控制台', value: 'CONSOLE'},
];
/**
 * 搜索表单设置
 * @rules:  是否验证       {Boolean}
 * @inline: 是否内联       {Boolean}
 * @width:  label宽度     {String}
 * @align:  label对齐方式  {String}
 */
const searchFormSetting = {
    rules: false,
    inline: true,
    ref: 'searchForm',
    width: '70px',
    align: 'right'
}
/**
 * 搜索表单
 * @type: 输入框的类型
 * @label: 输入框的label
 * @module: 输入框的v-module属性，不写会默认咦中文首字母拼音作为改属性
 * 注：select需要配合options使用
 */
const searchFormGroup = [
    {label: '名称', type: 'input', module: 'name', width: '150px'},
    {label: '类型', type: 'select', options: typeOptions, width: '120px'},
    {label: '机械臂', type: 'select', options: armOptions, width: '130px'},
    {label: '臂系统', type: 'select', options: robotOptions, width: '150px'},
    {label: '主手', type: 'select', options: handOptions, width: '130px'},
    {label: '控制台', type: 'select', options: consoleOptions, width: '150px'},
    {label: '标定时间', type: 'date', width: '190px'},
    {label: '状态', type: 'select', options: statusOptions, width: '120px'},
]
/**
 * 搜索表单按钮事件
 * @name: 按钮名称
 * @event: 按钮事件名（子组件直接@eventName=handleCustomizeEvent）
 * @primary：按钮类型（按钮的颜色）
 * @icon：按钮的小图标
 */
const searchFormButton = [
    {name: '查询', event: 'search', type: 'primary', icon: 'el-icon-search'},
    {name: '重置', event: 'reset', icon: 'el-icon-refresh-left'},
    {name: '一键导出', event: 'export', icon: 'el-icon-download'},
    {name: '添加记录', event: 'upload', icon: 'el-icon-upload'},
    {name: '删除选中', event: 'delete', type: 'danger', icon: 'el-icon-delete'},
    {name: '绘制选中', event: 'plot', type: 'success', icon: 'el-icon-success'},
]

/**
 * 表格表头信息
 * @chineseToPinYin: 这是封装的根据中文汉字转换为拼音的方法
 * @prop: 表头字段名
 * @filter: 数据过滤器
 * @label: 表头显示名称
 */
// function addressFilter (value) {
//   return addressOptions.filter(i => i.value === value)[0].label
// }
function robotFilter(value) {
    return robotOptions.filter(i => i.value === value)[0].label
}

function armFilter(value) {
    return armOptions.filter(i => i.value === value)[0].label
}

function statusFilter(value) {
    return statusOptions.filter(i => i.value === value)[0].label
}

function typeFilter(value) {
    return typeOptions.filter(i => i.value === value)[0].label
}

function handFilter(value) {
    return handOptions.filter(i => i.value === value)[0].label
}

function consoleFilter(value) {
    return consoleOptions.filter(i => i.value === value)[0].label
}

const tableTitle = [
    {prop: 'name', label: '名称', width: '160'},
    {prop: 'type', label: '类型', filter: typeFilter, width: '60'},
    {prop: 'robot', label: '臂系统', filter: robotFilter, width: '60'},
    {prop: 'arm', label: '机械臂', filter: armFilter, width: '60'},
    {prop: 'hand', label: '主手', filter: handFilter, width: '60'},
    {prop: 'console', label: '控制台', filter: consoleFilter, width: '60'},
    {prop: 'start_time', label: '开始时间', width: '140'},
    {prop: 'end_time', label: '结束时间', width: '140'},
    {prop: 'status', label: '状态', filter: statusFilter, width: '60'},
    {prop: 'worker', label: '操作者'},
    {prop: 'remarks', label: '备注', width: '180'},
    {prop: 'result', event: 'upload-result', label: '标定结果', text: '上传'},
    {prop: 'params', event: 'upload-params', label: '标定参数', text: '上传'},
    {prop: 'dataset', event: 'upload-dataset', label: '标定数据', text: '上传'},
    {prop: 'source_data', event: 'source-files', label: '原始数据', text: '详情'},
]
/**
 * 表格按钮事件
 * @event: 按钮事件名（子组件直接@eventName=handleCustomizeEvent）
 * @primary：按钮类型（按钮的颜色）
 */
const tableButton = [
    {label: '编辑', event: 'edit', type: 'primary'},
    {label: '删除', event: 'delete', type: 'danger'},
    {label: '导出MAT', event: 'export', type: 'success'}
]
/**
 * 弹出层表单
 */
const dialogFormSetting = {
    rules: false,
    inline: false,
    ref: 'dialogForm',
    width: '90px',
    align: 'left'
}

const typeFormGroup = [
    {label: '机械臂', type: 'select-equipment', required: true, kind: 'ROBOT', options: armOptions},
    {label: '臂系统', type: 'select-equipment', required: true, kind: 'ROBOT', options: robotOptions},
    {label: '主手', type: 'select-equipment', required: true, kind: 'CONSOLE', options: handOptions},
    {label: '控制台', type: 'select-equipment', required: true, kind: 'CONSOLE', options: consoleOptions},
]

const dialogFormGroup = [
    {label: '名称', type: 'input', required: true},
    {label: '类型', type: 'type', required: true, options: typeOptions, group: typeFormGroup},
    // { label: '机械臂', type: 'select-equipment', required: true, kind: 'ROBOT', options: armOptions},
    // { label: '臂系统', type: 'select-equipment', required: true, kind: 'ROBOT', options: robotOptions},
    // { label: '主手', type: 'select-equipment', required: true, kind: 'CONSOLE', options: handOptions},
    // { label: '控制台', type: 'select-equipment', required: true, kind: 'CONSOLE', options: consoleOptions},
    {label: '标定时间', type: 'datetimerange', required: true},
    {label: '状态', type: 'select', required: true, options: statusOptions},
    {label: '操作者', type: 'input', required: false},
    {label: '备注', type: 'textarea', required: false}
]

const dialogFormButton = [
    {name: '确定', event: 'confirm', type: 'primary'},
    {name: '取消', event: 'cancel'}
]

const uploadResultFormGroup = [
    {label: '标定结果', type: 'textarea', readonly: true},
    {
        label: '结果上传',
        type: 'upload-drag',
        action: '/api/calibration/upload/',
        limit: 1,
        tip: '请上传标定结果的MAT格式文件'
    }
]

export {
    searchFormSetting,
    searchFormGroup,
    searchFormButton,
    tableTitle,
    tableButton,
    dialogFormSetting,
    dialogFormGroup,
    dialogFormButton,
    uploadResultFormGroup,
    typeFormGroup,
    handOptions,
    armOptions
}
